/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.unal.bioingenium.kbmed.util.checker;

import java.util.HashMap;

/**
 *
 * @author Alejandro Riveros Cruz
 */
public class ThreadedChecker {

    private static HashMap<Object, Checker> registeredCheckers = new HashMap<Object, Checker>();

    /**
     * 
     * @param object
     * @param message
     */
    public static void addCheck(Object object, String message) {
        if (!registeredCheckers.containsKey(object)) {
            Checker checker = new Checker(object, message);
            registeredCheckers.put(object, checker);
            checker.start();
        }
    }

    /**
     * 
     * @param object
     * @param message
     * @param cycle
     */
    public static void addCheck(Object object, String message, int cycle) {
        if (!registeredCheckers.containsKey(object)) {
            Checker checker = new Checker(object, message, cycle);
            registeredCheckers.put(object, new Checker(object, message, cycle));
            checker.start();
        }
    }

    /**
     * 
     * @param object
     */
    public static void removeCheck(Object object) {
        registeredCheckers.get(object).stopChecking();
        registeredCheckers.remove(object);
    }
}
